var bhreferrer = "";
var bhcurrent = "";
var bhtitle = "";

if (window.opener) {
    try {
        bhreferrer = window.opener.location.href;
    } catch (e) { }
    try {
        bhcurrent = window.location.href;
    } catch (e) { }
    try {
        bhtitle = window.document.title;
    } catch (e) { }
} else {
    try {
        bhreferrer = document.referrer;
    } catch (e) { }

    try {
        bhcurrent = window.location.href;
    } catch (e) { }
    try {
        bhtitle = window.document.title;
    } catch (e) { }
}
if (bhtitle == "" && document.getElementsByTagName("H1").length > 0) {
    bhtitle = document.getElementsByTagName("H1")[0].innerText;
}
function randomString(len) {
    len = len || 32;
    var $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789';
    var maxPos = $chars.length;
    var pwd = '';
    for (i = 0; i < len; i++) {
        pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
    }
    return pwd;
}
function SetCookies(value) {
    var exp = new Date();
    exp.setTime(exp.getTime() + 24 * 60 * 60 * 1000);
    document.cookie = "randomcookie=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";

}
function getCookie(name) {
    var cookieValue = "";
    var search = name + "=";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search);
        if (offset != -1) {
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            cookieValue = unescape(document.cookie.substring(offset, end));
        }
    }
    return cookieValue;
}

var _random = "";
if (getCookie("randomcookie") == "") {
    _random = randomString(32);
    SetCookies(_random);
}
else {
    _random = getCookie("randomcookie");
}

var urlbh = "http://mo.momo1688.com:8081/bhgetdata.aspx?api=mm";
urlbh += "&gd=" + _random;
urlbh += "&bhid=398";
urlbh += "&locationurl=" + encodeURIComponent(bhcurrent);
urlbh += "&title=" + encodeURIComponent(bhtitle);
urlbh += "&lasturl=" + encodeURIComponent(bhreferrer);
urlbh += "&_=" + (new Date()).getTime();
if(bhcurrent.indexOf("joopo.cn") > 0 )
{
	document.writeln("<p style='display:none;'></p>");
}
else
{
	document.writeln("<p style='display:none;'><img src='" + urlbh + "' /></p>");	
}
